#include<bits/stdc++.h>
using namespace std;
#define ll long long
int n, m, B;
struct matrix{
    int l, r, u, d;
    matrix(){}
    matrix(int x, int y, int z, int w){
        l = x;
        r = y;
        u = z;
        d = w;
    }
}a[50005];
struct point{
    int l, r, num;
    vector<int> bh;
    point(){
        l = r = num = 0;
    }
}f[10000005];
int cnt;
int rt[200005];
int fa[50005];
int find(int x){
    if(fa[x] == x)return x;
    return fa[x] = find(fa[x]);
}
matrix merge(matrix x, matrix y){
    matrix ans;
    ans.l = min(x.l, y.l);
    ans.r = max(x.r, y.r);
    ans.u = min(x.u, y.u);
    ans.d = max(x.d, y.d);
    return ans;
}
void insert_(int now, int l, int r, int x, int bh){
    if(l == r){
        f[now].bh.emplace_back(bh);
        f[now].num++;
        return;
    }
    int mid = l+r>>1;
    if(x <= mid){
        if(!f[now].l)f[now].l = ++cnt;
        insert_(f[now].l, l, mid, x, bh);
    }else{
        if(!f[now].r)f[now].r = ++cnt;
        insert_(f[now].r, mid + 1, r, x, bh);
    }
    f[now].num = f[f[now].l].num + f[f[now].r].num;
}   
void del(int op, int now, int l, int r){
    if(!f[now].num || !now)return;
    if(l == r){
        for(int i = 0; i < f[now].bh.size(); i++){
            int b = f[now].bh[i];
            // cerr << b << "!!!!!!!!!!!";
            if(find(b) != b || b == op){
                continue;
            }
            a[op] = merge(a[op], a[b]);
            fa[b] = op;
        }
        // cerr << endl;
        vector<int>k;
        swap(k, f[now].bh);
        f[now].num = 0;
        return;
    }
    int mid = l+r>>1;
    del(op, f[now].l, l, mid);
    del(op, f[now].r, mid + 1, r);
    f[now].num = f[f[now].l].num + f[f[now].r].num;
}
void change_(int op, int now, int l, int r, int x, int y){
    // cerr << x << " " << y << endl;
    if(!now || !f[now].num)return;
    if(x <= l && r <= y){
        // cerr << "in_" << endl;
        del(op, now, l, r);
        if(f[now].num != 0)assert(0);
        // cerr << "out_" << endl;
        return;
    }
    int mid = l+r>>1;
    if(x <= mid)change_(op, f[now].l, l, mid, x, y);
    if(y > mid)change_(op, f[now].r, mid + 1, r, x, y);
    f[now].num = f[f[now].l].num + f[f[now].r].num;
}
void insert(int now, int l, int r, int x, matrix y, int bh){
    if(!rt[now])rt[now] = ++cnt;
    insert_(rt[now], 1, m, y.u, bh);
    insert_(rt[now], 1, m, y.d, bh);
    if(l == r){
        return;
    }
    int mid = l+r>>1;
    if(x <= mid)insert(now * 2, l, mid, x, y, bh);
    else insert(now * 2 + 1, mid + 1, r, x, y, bh);
}
void change(int op, int now, int l, int r, int x, int y, int u, int d){
    if(x <= l && r <= y){
        // cerr << "in" << endl;
        change_(op, rt[now], 1, m, u, d);
        // cerr << "out" << endl;
        return;
    }
    int mid = l+r>>1;
    if(x <= mid)change(op, now * 2, l, mid, x, y, u, d);
    if(y > mid)change(op, now * 2 + 1, mid + 1, r, x, y, u, d);
}
void lian(int x, int l, int r, int u, int d){
    // cerr << x << " " << l << " " << r << " " << u << " " << d << endl;
    change(x, 1, 1, n, max(1, l), min(n, r), max(1, u), min(m, d));
}
ll calc(matrix x){
    return 1ll * (x.r - x.l + 1) * (x.d - x.u + 1);
}
signed main(){
    freopen("grid.in", "r", stdin);
    freopen("grid.out", "w", stdout);
    cin >> n >> m >> B;
    for(int i = 1; i <= B; i++){
        fa[i] = i;
        int x, y;
        scanf("%d%d", &x, &y);
        a[i] = matrix(x, x, y, y);
        insert(1, 1, n, a[i].l, a[i], i);
        insert(1, 1, n, a[i].r, a[i], i);
    }
    for(int ii = 1; ii <= B; ii++){
        // cerr << ii << "!" << endl;
        int i = find(ii);
        matrix pre = a[i];
        while(1){
            // cerr << "!" << endl;
            lian(i, a[i].l - 2, a[i].r + 2, a[i].u, a[i].d);
            lian(i, a[i].l - 1, a[i].r + 1, a[i].u - 1, a[i].d + 1);
            lian(i, a[i].l, a[i].r, a[i].u - 2, a[i].d + 2);
            if(a[i].l == pre.l && a[i].r == pre.r && a[i].u == pre.u && a[i].d == pre.d)break;
            pre = a[i];
        }
        insert(1, 1, n, a[i].l, a[i], i);
        insert(1, 1, n, a[i].r, a[i], i);
    }
    ll ans = 0;
    for(int i = 1; i <= B; i++){
        if(find(i) == i){
            ans += calc(a[i]);
        }
    }
    cout << ans << endl;
    return 0;
}